package com.zkw.group.controller;

import com.alibaba.fastjson.JSON;
import com.zkw.group.entity.CourseIndicatorSupport;
import com.zkw.group.entity.ProfesIndicatorOne;
import com.zkw.group.entity.ProfesIndicatorTwo;
import com.zkw.group.entity.QueryInfo;
import com.zkw.group.service.PublicProfesIndicatorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@Api(description = "公众查看毕业生能力要求指标有关信息")
@CrossOrigin
@RestController
@RequestMapping("/Publics")
public class PublicProfesIndicatorController {

    @Autowired
    private PublicProfesIndicatorService publicProfesIndicatorService;

    @ApiOperation(value = "分页查询一级指标列表")
    @GetMapping("/AllProfesIndicatorOne")
    public String getAllIndicatorOneList(QueryInfo queryInfo) {
        int numbers = publicProfesIndicatorService.getIndicatorOneCounts(queryInfo.getQuery());
        int pageStart = (queryInfo.getPageNum()-1)*queryInfo.getPageSize();
        List<ProfesIndicatorOne> profesIndicatorOnes = publicProfesIndicatorService.getAllIndicatorOneList(queryInfo.getQuery(),pageStart,queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("numbers",numbers);
        res.put("data", profesIndicatorOnes);
        return JSON.toJSONString(res);
    }

    @ApiOperation(value = "分页查询二级指标列表")
    @GetMapping("/AllProfesIndicatorTwo")
    public String getAllIndicatorTwoList(QueryInfo queryInfo) {
        int numbers = publicProfesIndicatorService.getIndicatorTwoCounts(queryInfo.getQuery(),queryInfo.getRole());
        int pageStart = (queryInfo.getPageNum()-1)*queryInfo.getPageSize();
        List<ProfesIndicatorTwo> profesIndicatorTwos = publicProfesIndicatorService.getAllIndicatorTwoList(queryInfo.getQuery(),queryInfo.getRole(),pageStart,queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("numbers",numbers);
        res.put("data", profesIndicatorTwos);
        return JSON.toJSONString(res);
    }

    @ApiOperation(value = "分页查询课程对应能力指标支撑度信息")
    @GetMapping("/AllCourseIndicatorSupport")
    public String getAllCourseIndicatorSupportList(QueryInfo queryInfo) {
        int numbers = publicProfesIndicatorService.getCourseIndicatorSupportCounts(queryInfo.getQuery(),queryInfo.getRole());
        int pageStart = (queryInfo.getPageNum()-1)*queryInfo.getPageSize();
        List<CourseIndicatorSupport> courseIndicatorSupports = publicProfesIndicatorService.getAllCourseIndicatorSupportList(queryInfo.getQuery(),queryInfo.getRole(),pageStart,queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("numbers",numbers);
        res.put("data",courseIndicatorSupports);
        return JSON.toJSONString(res);
    }
}
